import com.jme3.app.SimpleApplication;
import com.jme3.light.DirectionalLight;
import com.jme3.material.Material;
import com.jme3.math.FastMath;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Mesh;
import com.jme3.scene.shape.Box;
import com.jme3.system.AppSettings;
import javafx.scene.canvas.Canvas;

public class App extends SimpleApplication {
    Canvas canvas;

    public App(Canvas canvas) {
        this.canvas = canvas;

    }
    Geometry geom;
    @Override
    public void simpleInitApp() {
        flyCam.setEnabled(false);
        MYScreenshotAppState myScreenshotAppState = new MYScreenshotAppState(canvas);
        stateManager.attach(myScreenshotAppState);
        // #1 创建一个方块形状的网格
        Mesh box = new Box(1, 1, 1);

        // #2 加载一个感光材质
        Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");

        // #3 创建一个几何体，应用刚才和网格和材质。
         geom = new Geometry("Box");
        geom.setMesh(box);
        geom.setMaterial(mat);

        // #4 创建一束定向光，并让它斜向下照射，好使我们能够看清那个方块。
        DirectionalLight sun = new DirectionalLight();
        sun.setDirection(new Vector3f(-1, -2, -3));

        // #5 将方块和光源都添加到场景图中
        rootNode.attachChild(geom);
        rootNode.addLight(sun);
    }

    @Override
    public void simpleUpdate(float tpf) {
        super.simpleUpdate(tpf);
        // 旋转速度：每秒360°
        float speed = FastMath.PI/2;
        // 让方块匀速旋转
        geom.rotate(0, tpf * speed, 0);
    }

    public static void main(String[] args) {
        AppSettings appSettings;
    }
}
